/**
 * 
 */
package aiproject3.predictors;

import aiproject3.models.KnowledgeBase;

/**
 * @author Chris
 *
 */
public class MajorityPredictor<U> implements Predictor<U> {

	private U _currentPrediction;
	private KnowledgeBase<U, Integer> _model;
	
	public MajorityPredictor(KnowledgeBase<U, Integer> model) {
		this._model = model;
	}
	
	
	public U predictNext() {
		return _currentPrediction;
	}

	
	public void updatePredictor(U unit) {
		if (_currentPrediction == null)
			_currentPrediction = unit;
		else if (_model.contains(unit) && _model.contains(_currentPrediction))
			if (_model.getValueFromModel(unit) >= _model.getValueFromModel(_currentPrediction))
				_currentPrediction = unit;
	}

}
